All Questions
86 questions
0votes
3answers
77views
Keeping owners in a folder copy
I'm trying to copy a folder (SRC) containing some files and subfolders. The content and SRC itself have setgid bit enabled (that is the s in place of the x in the group triplet). Furthermore, the ...
0votes
1answer
163views
Any command to exclude all types of files only? [duplicate]
Does rsync or cp have a command to exclude any type of file besides manually excluding extensions such as *.txt, *.pdf, *.jpg OR setting -maxdepth or using --exclude=dir/* (used with rsync which ...
3votes
1answer
156views
Hard link as destination of cp and rsync
Where do I find documentation of behavior of cp and rsync commands when the destination path shares the inode with another path? In other words, when I do $ cp [options] src dest $ rsync [options] src ...
0votes
1answer
65views
How to copy a directory structure and rename a subdirectory in the destination
Given this directory structure $ lsd --tree ...
0votes
1answer
76views
How to find a file and copy its directory without copying the other files in that same directory?
I have a lot of different folders with pdf files and other extensions. I want to copy all the pdf files to another destination. But if I do that with find like this: "${SEARCHDIR}" -iname &...
1vote
1answer
634views
Copying/moving and renaming files from multiple subdirectories to parent directory
I have multiple directories, and each one of those directories contains an "example" directory which in turn contains images. What I want to do, is to add a textual suffix at the end of a ...
0votes
2answers
2kviews
Copy a file with its parent dirs to a destination directory
Source file : ~/SCRIPTS/script Destination directory : ~/TMP/LAB the command should be something like : <command> <option> ~/SCRIPTS/script ~/TMP/LAB Desired result after the command : ~/...
-1votes
1answer
2kviews
copying files with same names
I have directories --dir1 image1 image2 image3 --dir2 image1 image2 image3 --dir3 image1 image2 image3 I want to copy all the files (that have the same names) from ...
1vote
0answers
1kviews
Moving sparse files
cp not only auto-detects sparse files but also has --sparse=always option. I wonder if mv works with the same mechanism or the safe way for moving sparse files is cp && rm Or is there any ...
1vote
1answer
300views
How do I duplicate file n times and then create a function in .zshrc?
This may be a duplicate of Duplicate file x times in command shell and is definitely a duplicate of How to duplicate a file a number of times while embedding an index in each file but the person who ...
0votes
2answers
287views
How to copy target files using symlinks and a list of file names
I would like to copy many files. I have their location as a set of symbolic links whose names are stored as lines in a txt file. So I am using cp and need to combine the readlink and cat/pipe ...
0votes
4answers
624views
cp files with pattern with middle directory variable
I have a directory l ── 10020 │ ├── live │ │ ├── 211231.jpg │ │ ├── 211231_BB.txt │ │ ├── 448378.jpg │ │ ├── 448378_BB.txt │ │ ├── 460830.jpg │ │ └── 460830_BB.txt │ └── ...
6votes
2answers
3kviews
If cp's destination path turns out to be a directory, how do I avoid mistakenly creating files inside that directory?
My understanding of cp src dest is: If src is a file and dest doesn't exist, but its parent directory does, dest is created. If src is a file and dest is a file, dest is overwritten with the contents ...
0votes
2answers
731views
Copy file in multiple (variable) folders
I want to copy files in multiple subfolders with variable subfolder names. Example: mkdir rootdir mkdir rootdir/dir1 mkdir rootdir/dir2 mkdir rootdir/dir3 touch rootdir/dir1/foo.txt touch rootdir/dir2/...
0votes
0answers
494views
single command to `mv`/rename/move a file and set the user, group & permissions?
I can copy a file with cp. But with install I can copy a file, and set the owner, group and permissions on the new destination file, which is useful. With mv, I can rename/move a file, which (if it's ...